
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections.Generic;
using System.Text;

using Swaf;
using Swaf.Container;
using Swaf.BizObj;
using Swaf.BizRule;
using Swaf.Security;
using Swaf.Gui;

using UserLogin.Gui;
using Syrinx.Gui;
namespace UserManagement.Gui
{
	public class UserUserGroupMembershipBizProc : Swaf.Gui.BaseBusinessProcess
	{
		public UserUserGroupMembershipBizProc(ActiveBizProc procState)
			: base(procState)
		{
		}

		protected override void setupRuleNames()
		{
			base.m_getMasterBizObjListRule = "getCompanyUserGroups";
			base.m_getBizObjListRule = "getUserUserGroups";
			base.m_bizObjListCheckedChangedRule = "setUserUserGroupMembership";
		}

		protected override Privileges CurrentEditPrivilege
		{
			get
			{
				return CurrentPrincipal.getPrivilege("AppFunctions.ManageUsers");
			}
		}

		//public void initiateDataRetrieval(Swaf.Gui.ParentBizProcInfo parent)
		//{
		//    if (parent != null && parent.Parent != null)
		//    {
		//        m_parentBizObj = ((IBizObjBizProcess)parent.Parent).SelectedBizObj;
		//        if (m_parentBizObj != null && m_parentBizObj.containsField("companyId"))
		//            base.initiateDataRetrieval(m_baseRule, m_parentBizObj.get("companyId") as Swaf.BGuid.Guid);
		//    }
		//}
		//protected IBizObjList calcUserUserGroups(IBizObjList bizobjs)
		//{
		//    IBizObjList userUserGrouplist = App.bizObjMgr.createList("UserGroup");
		//    if (m_parentBizObj != null && bizobjs != null)
		//    {
		//        IResults rc = App.ruleMgr.execute("getUserUserGroups", m_parentBizObj.get("id"));
		//        if (rc.ExceptionInfo != null)
		//            OnBizProcException(this, GetType().Name + "calcUserUserGroups", rc.ExceptionInfo);
		//        else
		//        {
		//            userUserGrouplist = rc.CallResults as IBizObjList;
		//            foreach (IBizObj obj in userUserGrouplist)
		//            {
		//                IBizObj ug = bizobjs.search("id", obj.get("id") as Swaf.BGuid.Guid);
		//                if (ug != null)
		//                    ug.put("checked", true);
		//            }
		//        }
		//        return bizobjs;
		//    }
		//    return userUserGrouplist;
		//}

		//public bool updateBizObj(IBizObj obj)
		//{
		//    if (m_parentBizObj != null && m_parentBizObj.containsField("groups"))
		//    {
		//        IBizObjList list = App.bizObjMgr.createList(m_bizobjs.objectType.Name);
		//        foreach (IBizObj group in m_bizobjs)
		//            if ("true".Equals(group.get("checked").ToString().ToLower()))
		//                list.Add(group);
		//        m_parentBizObj.put("groups", list);
		//        IResults rc = App.ruleMgr.execute(m_updateBizObjRule, new object[] { this.m_parentBizObj });
		//        if (rc.ExceptionInfo != null)
		//            OnBizProcException(this, this.GetType().Name + "updateBizObj", rc.ExceptionInfo);
		//    }
		//    return false;
		//}
	}
}
